// Table A4. Foreign versus domestic firms
use "eseewithinfirm.dta", clear

local filename "tableA4"
xi: xtreg lnval i.crisis*longinv8 i.category if domfir==1 , fe cluster(firmid)
outreg2 using "`filename'", word replace label  dec(3)  nocons addtext(Sample, domestic firms) keep(_IcriXlong*)
xi: xtreg lnval i.crisis*longinv8 i.category if domfir==0 , fe cluster(firmid)
outreg2 using "`filename'", word  label  dec(3)  nocons addtext(Sample, foreign firms)  keep(_IcriXlong*)
xi: xtreg lnval i.year*longinv8 i.category if domfir==1 , fe cluster(firmid)
foreach year in 2008 2009 2010 {
test _IyeaXlon_2007=_IyeaXlon_`year'
local f`year'=r(F)
local p`year'=r(p)
}
outreg2 using "`filename'", word  label  dec(3)  nocons addtext(Sample, domestic firms) keep(_IyeaXlon*) ///
	addstat(F-stat 2007=2008, `f2008', p-val 2008, `p2008',F-stat 2007=2009, `f2009', p-val 2009, `p2009',F-stat 2007=2010, `f2010', p-val 2010, `p2010')
xi: xtreg lnval i.year*longinv8 i.category if domfir==0, fe cluster(firmid)
foreach year in 2008 2009 2010 {
test _IyeaXlon_2007=_IyeaXlon_`year'
local f`year'=r(F)
local p`year'=r(p)
}
outreg2 using "`filename'", word  label  dec(3)  nocons addtext(Sample, foreign firms) keep(_IyeaXlon*) ///
	addstat(F-stat 2007=2008, `f2008', p-val 2008, `p2008',F-stat 2007=2009, `f2009', p-val 2009, `p2009',F-stat 2007=2010, `f2010', p-val 2010, `p2010')

	